#pragma once

#include "Framework.hpp"
#include "Camera.hpp"

// Camera for displaying, scrolling and (optionally) zooming 2D image.
class ObjectCamera2d
{
public:
	// Configuration
	
	bool ScalingEnabled;
	bool KeyboardScalingEnabled, KeyboardPanEnabled;
	float ScalingSpeed, FastSpeedFactor;
	float KeyboardScalingSpeed, KeyboardPanSpeed;

	// Current data
	
	common::VEC2 Bias;
	float Scale;

	ObjectCamera2d();
	void Update();

	void UnitsToScreen(common::VEC2 &out, const common::VEC2 &unitsPos) const;
	void ScreenToUnits(common::VEC2 &out, const common::VEC2 &screenPos) const;

	bool OnMouseMove( const common::VEC2 &Pos );
	bool OnMouseButton( const common::VEC2 &Pos, frame::MOUSE_BUTTON Button, frame::MOUSE_ACTION Action );
	bool OnMouseWheel( const common::VEC2 &Pos, float Delta );

private:
	bool m_IsPanning;
	VEC2 m_PanLastPos;
};

// Camera for displaying, optionally zooming and paning a 3D object.
class ObjectCamera3d
{
public:
	// Configuration
	
	bool ZoomEnabled, PanEnabled;
	float OrbitSpeed, ZoomSpeed, FastSpeedFactor, PanSpeed;

	// Current data
	
	Camera m_Camera;

	ObjectCamera3d();

	bool OnMouseMove( const common::VEC2 &Pos );
	bool OnMouseButton( const common::VEC2 &Pos, frame::MOUSE_BUTTON Button, frame::MOUSE_ACTION Action );
	bool OnMouseWheel( const common::VEC2 &Pos, float Delta );

private:
	enum MODE
	{
		MODE_NONE,
		MODE_ORBIT,
		MODE_PAN,
	};

	MODE m_Mode;
	common::VEC2 m_LastPos; // Used only in modes except MODE_NONE.
};
